
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 05/07/2013 23:07:47
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class LayoutMenu_Translation
    /// </summary>
    [Serializable]
    public partial class LayoutMenu_Translation : _DomainLayer_Base
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual int Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_LayoutMenu.
        /// </summary>
        /// <value>The FK_LayoutMenu.</value>
        /// <remarks>
        /// Foregn key of LayoutMenu_Translation
        /// 
        /// </remarks>
        public virtual int FK_LayoutMenu
        {
            get { return _fK_LayoutMenu; }
            set
            {
                if (_fK_LayoutMenu != value)
                {
                    if (LayoutMenu != null && LayoutMenu.Id != value)
                    {
                        LayoutMenu = null;
                    }
                    _fK_LayoutMenu = value;
                }
            }
        }
        private int _fK_LayoutMenu;
    	
        /// <summary>
        /// Gets or sets FK_Language.
        /// </summary>
        /// <value>The FK_Language.</value>
        /// <remarks>
        /// Foregn key of LayoutMenu_Translation
        /// 
        /// </remarks>
        public virtual int FK_Language
        {
            get { return _fK_Language; }
            set
            {
                if (_fK_Language != value)
                {
                    if (Language != null && Language.Id != value)
                    {
                        Language = null;
                    }
                    _fK_Language = value;
                }
            }
        }
        private int _fK_Language;
    	
        /// <summary>
        /// Gets or sets Active.
        /// </summary>
        /// <value>The Active.</value>
        public virtual bool Active
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets MenuNameURLFormatted.
        /// </summary>
        /// <value>The MenuNameURLFormatted.</value>
        public virtual string MenuNameURLFormatted
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets ButtonCaption.
        /// </summary>
        /// <value>The ButtonCaption.</value>
        public virtual string ButtonCaption
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets ButtonToolTip.
        /// </summary>
        /// <value>The ButtonToolTip.</value>
        public virtual string ButtonToolTip
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets CssClass.
        /// </summary>
        /// <value>The CssClass.</value>
        public virtual string CssClass
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion
        #region Navigation Properties
    
        /// <summary>
        /// Link LayoutMenu_Translation to all Structure_Page
        /// </summary>
        public virtual ICollection<Structure_Page> Structure_Page
        {
            get
            {
                if (_structure_Page == null)
                {
                    var newCollection = new FixupCollection<Structure_Page>();
                    newCollection.CollectionChanged += FixupStructure_Page;
                    _structure_Page = newCollection;
                }
                return _structure_Page;
            }
            set
            {
                if (!ReferenceEquals(_structure_Page, value))
                {
                    var previousValue = _structure_Page as FixupCollection<Structure_Page>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupStructure_Page;
                    }
                    _structure_Page = value;
                    var newValue = value as FixupCollection<Structure_Page>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupStructure_Page;
                    }
                }
            }
        }
        private ICollection<Structure_Page> _structure_Page;
        public virtual Language Language
        {
            get { return _language; }
            set
            {
                if (!ReferenceEquals(_language, value))
                {
                    var previousValue = _language;
                    _language = value;
                    FixupLanguage(previousValue);
                }
            }
        }
        private Language _language;
        public virtual LayoutMenu LayoutMenu
        {
            get { return _layoutMenu; }
            set
            {
                if (!ReferenceEquals(_layoutMenu, value))
                {
                    var previousValue = _layoutMenu;
                    _layoutMenu = value;
                    FixupLayoutMenu(previousValue);
                }
            }
        }
        private LayoutMenu _layoutMenu;

        #endregion
        #region Association Fixup
    
        private void FixupLanguage(Language previousValue)
        {
            if (previousValue != null && previousValue.LayoutMenu_Translation.Contains(this))
            {
                previousValue.LayoutMenu_Translation.Remove(this);
            }
    
            if (Language != null)
            {
                if (!Language.LayoutMenu_Translation.Contains(this))
                {
                    Language.LayoutMenu_Translation.Add(this);
                }
                if (FK_Language != Language.Id)
                {
                    FK_Language = Language.Id;
                }
            }
        }
    
        private void FixupLayoutMenu(LayoutMenu previousValue)
        {
            if (previousValue != null && previousValue.LayoutMenu_Translation.Contains(this))
            {
                previousValue.LayoutMenu_Translation.Remove(this);
            }
    
            if (LayoutMenu != null)
            {
                if (!LayoutMenu.LayoutMenu_Translation.Contains(this))
                {
                    LayoutMenu.LayoutMenu_Translation.Add(this);
                }
                if (FK_LayoutMenu != LayoutMenu.Id)
                {
                    FK_LayoutMenu = LayoutMenu.Id;
                }
            }
        }
    
        private void FixupStructure_Page(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (Structure_Page item in e.NewItems)
                {
                    item.LayoutMenu_Translation = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (Structure_Page item in e.OldItems)
                {
                    if (ReferenceEquals(item.LayoutMenu_Translation, this))
                    {
                        item.LayoutMenu_Translation = null;
                    }
                }
            }
        }

        #endregion
    }
}
